import { defineStore } from 'pinia';
import { ref } from 'vue';

export const useHomeStore = defineStore('home', () => {
  // 侧边栏显示状态（原showNote）
  const showSideBox = ref<boolean>(true);
  // 侧边栏展开状态
  const expandSideBox = ref<boolean>(false);
  // 内容标题
  const contentTitle = ref<string>('');

  // 切换侧边栏显示状态
  const toggleSideBox = () => {
    showSideBox.value = !showSideBox.value;
    // 收回侧边栏时需要取消展开模式
    if (!showSideBox.value) {
      expandSideBox.value = false;
    }
  };

  // 设置侧边栏显示状态
  const setShowSideBox = (value: boolean) => {
    showSideBox.value = value;
    // 收回侧边栏时需要取消展开模式
    if (!showSideBox.value) {
      expandSideBox.value = false;
    }
  };

  // 切换侧边栏展开状态
  const toggleExpandSideBox = () => {
    expandSideBox.value = !expandSideBox.value;
  };

  // 设置内容标题
  const setContentTitle = (title: string) => {
    contentTitle.value = title;
  };

  return {
    showSideBox,
    toggleSideBox,
    setShowSideBox,
    expandSideBox,
    toggleExpandSideBox,
    contentTitle,
    setContentTitle,
  };
});
